var tableIns;//表格实例
layui.use(['laydate', 'form'], function() {
	var form = layui.form;
	io.get("/ep/data/comm_query_industry_list_l3", function(res) {
		let map = new Map();
		for (let v of res.data) {
			map.set(v.label, v.value);
		}
		map2Select(map, 'industry');
		form.render();
	});
	var laydate = layui.laydate;
	let today = new Date();
	let twoYearsAgo = new Date();
	twoYearsAgo.setFullYear(today.getFullYear() - 3);
	laydate.render({
		elem: '#startDate'
		, type: 'date'
		, format: 'yyyyMMdd'
		, value: twoYearsAgo
	});
	laydate.render({
		elem: '#endDate'
		, type: 'date'
		, format: 'yyyyMMdd'
		, value: today
	});

	form.on('submit(search)', function(formData) {
		render(formData.field);
	});

});

function render(params) {
	io.get("/stock/industry/main-money-flow?statExp=buy_elg_amount-sell_elg_amount", function(res) {
		bi.renderBar({ elementId: 'moneyFlow', data: res.data, title: '超大单资金流向', subtext: params.industry,style:'macarons2' });
	}, params);
	
	io.get("/stock/industry/main-money-flow?statExp=buy_lg_amount-sell_lg_amount", function(res) {
		bi.renderBar({ elementId: 'moneyFlow2', data: res.data, title: '大单资金流向', subtext: params.industry,style:'macarons2' });
	}, params);
	
	io.get("/stock/industry/main-money-flow?statExp=buy_md_amount-sell_md_amount", function(res) {
		bi.renderBar({ elementId: 'moneyFlow3', data: res.data, title: '中单资金流向', subtext: params.industry,style:'macarons2' });
	}, params);
	
	io.get("/stock/industry/main-money-flow?statExp=buy_sm_amount-sell_sm_amount", function(res) {
		bi.renderBar({ elementId: 'moneyFlow4', data: res.data, title: '小单资金流向', subtext: params.industry,style:'macarons2' });
	}, params);
	io.get("/stock/industry/market-value", function(res) {
		bi.renderBar({ elementId: 'marketValue', data: res.data, title: '公司市值', subtext: params.industry,style:'macarons2' });
	}, params);
}
